//
//  TitlesCell.m
//  ToYourHeartNews
//
//  Created by XJing on 16/1/20.
//  Copyright © 2016年 www.lanou3g.com 蓝鸥. All rights reserved.
//

#import "TitlesCell.h"

@implementation TitlesCell
- (void)dealloc
{
    [_img release];
    [_jieshaoLable release];
    [_contentsLable release];
    [_kindLable release];
    [_photo release];
    [_nameLable release];
    [super dealloc];
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.img = [[UIImageView alloc]init];
        _img.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_img];
        [_img release];
        
        self.jieshaoLable = [[UILabel alloc]init];
        //  _jieshaoLable.backgroundColor = [UIColor yellowColor];
        [self.contentView addSubview:_jieshaoLable];
        [_jieshaoLable release];
        
        self.contentsLable = [[UILabel alloc]init];
        // _contentsLable.backgroundColor = [UIColor blueColor];
        [self.contentView addSubview:_contentsLable];
        [_contentsLable release];
        
        self.kindLable = [[UILabel alloc]init];
        //_kindLable.backgroundColor = [UIColor magentaColor];
        [self.contentView addSubview:_kindLable];
        [_kindLable release];
        
        self.attent = [UIButton buttonWithType:UIButtonTypeSystem];
        //_attent.backgroundColor = [UIColor cyanColor];
        [self.contentView addSubview:_attent];
        
        self.photo = [[UIImageView alloc]init];
        // _photo.backgroundColor = [UIColor greenColor];
        [_img addSubview:_photo];
        
        self.nameLable = [[UILabel alloc]init];
        // _nameLable.backgroundColor = [UIColor orangeColor];
        [_img addSubview:_nameLable];
    }
    return self;
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    //图片
    _img.frame = CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.frame.size.height / 3 * 2);
    //作者图片
    _photo.frame = CGRectMake(10, _img.frame.size.height / 4 * 3, _img.frame.size.width / 9, _img.frame.size.width / 9);
    _photo.layer.cornerRadius = _photo.frame.size.width / 2;
    _photo.clipsToBounds = YES;
    //作者姓名
    _nameLable.frame = CGRectMake(_photo.frame.origin.x + _photo.frame.size.width + 5, _photo.frame.origin.y + (_photo.frame.size.height / 2),self.contentView.frame.size.width - _photo.frame.size.width, _photo.frame.size.height / 2);
    _nameLable.textColor = [UIColor grayColor];
    _nameLable.font = [UIFont systemFontOfSize:16];
    //专题介绍
    _jieshaoLable.frame = CGRectMake(10, _img.frame.size.height + 10, self.contentView.frame.size.width - 10, _img.frame.size.height / 4);
    _jieshaoLable.numberOfLines = 0;
    //受关注数量
    _contentsLable.frame = CGRectMake(10, _jieshaoLable.frame.origin.y + _jieshaoLable.frame.size.height + 10, _jieshaoLable.frame.size.width / 4, _jieshaoLable.frame.size.height / 2);
    //专题分类
    _kindLable.frame = CGRectMake(_contentsLable.frame.origin.x + _contentsLable.frame.size.width , _contentsLable.frame.origin.y, _contentsLable.frame.size.width / 2, _contentsLable.frame.size.height);
    _kindLable.textColor = [UIColor blueColor];
    _kindLable.font = [UIFont systemFontOfSize:14];
    //关注按钮
    _attent.frame = CGRectMake(self.contentView.frame.size.width - _contentsLable.frame.size.width + 10, _contentsLable.frame.origin.y, _contentsLable.frame.size.width - 20, _contentsLable.frame.size.height);
    [_attent setTitle:@"+ 关注" forState:UIControlStateNormal];
    _attent.titleLabel.font = [UIFont systemFontOfSize:13];
    [_attent setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    _attent.layer.cornerRadius = 10;
    //设置按钮边框颜色
    CGColorSpaceRef colorSpaceRef2 = CGColorSpaceCreateDeviceRGB();
    CGColorRef color2 = CGColorCreate(colorSpaceRef2, (CGFloat[]){0,0,0,0.5});
    [_attent.layer setBorderColor:color2];
    [_attent.layer setBorderWidth:1];
    //    [_attent.layer setMasksToBounds:YES];
    _attent.clipsToBounds = YES;
    
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
